const WXAPI = require('apifm-wxapi')

async function getShop(id){
  const res = await WXAPI.shopSubdetail(id)
  if(res.code === 0){
    wx.setStorageSync('shopInfo',  res.data)
  }
}


function checkShop (){
  const  shop =  wx.getStorageSync('shopInfo')
  if(shop){
    return 
  }
  if(!shop){
    const  id =  wx.getStorageSync('shopIds')
    if(id){
      getShop(id)
    }else{
      wx.navigateTo({
        url: '/pages/shop/select?type=index',
      })
    }
  }
}


module.exports = {
  checkShop:checkShop,
  getShop:getShop,

}